/*************************************************************************
	> File Name: test.cpp
	> Author: Maureen 
	> Mail: Maureen@qq.com 
	> Created Time: 二  2/23 19:41:42 2021
 ************************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int brute_force(const char *s, const char *t) {
    for (int i = 0; s[i]; i++) {
        int flag = 1;
        for (int j = 0; t[j]; j++) {
            if (s[i + j] == t[j]) continue;
            flag = 0;
            break;
        }
        if (flag) return i;
    }
    return -1;
}

int getNextArray(const char *t, int &j, char input, int *next) {
    while (j != -1 && t[j + 1] != input) j = next[j];
    if (t[j + 1] == input) j += 1;
    return j;
}

int kmp(const char *s, const char *t) {
    int len_t = strlen(t);
    int *next = (int *)malloc(sizeof(int) * (len_t + 1));
    next[0] = -1;
    for (int i = 0, j = -1; t[i]; i++) next[i] = getNextArray(t, j, t[i], next);
    for (int i = 0, j = -1; s[i]; i++) {
        if (getNextArray(t, j, s[i], next) != len_t - 1) continue;
        return i - len_t + 1;
    }
    return -1;
}

int sunday(const char *s, const char *t) {
    int len_t = strlen(t);
    int len_s = strlen(s);
    int offset[256];
    for (int i = 0; i < 256; i++) offset[i] = len_t + 1;
    for (int i = 0; t[i]; i++) offset[t[i]] = len_t - i;
    for (int i = 0; i + len_t <= len_s; i += offset[s[i + len_t]]) {
        int flag = 1;
        for (int j = 0; t[j] && flag; j++) {
            flag = flag && s[i + j] == t[j];
        }
        if (flag) return i;
    }
    return -1;
}


int main() {
    char s[100], t[100];
    while (~scanf("%s%s", s, t)) {
        printf("brute_force(%s, %s) = %d\n", s, t, brute_force(s, t));
        printf("kmp(%s, %s) = %d\n", s, t, kmp(s, t));
        printf("sunday(%s, %s) = %d\n", s, t, sunday(s, t));
        printf("------------\n");
    }
    return 0;
}
